clear
rng(20)

outer_counter = 1;
repeats = 5;
num_comps = 10;
num_moments = 5;
parpool('local',num_comps)

%%% TARGETED DISEMBODIED MODEL Z COUNTERFACTUAL
simulated_data_z = [];
for z_US = 0.01:0.01:0.25
disp(z_US)
params = [0.1   0.0222    0.1398     1.5     7    0.8   z_US  max(0.01,z_US-0.069)];
iteration_data = zeros(1,num_moments);
counter=1;
while counter <= repeats
parfor computer_num = 1:num_comps
temp_data = steady_state_simulation_targeted_disembodied(params);
iteration_data = iteration_data+temp_data';
end
counter = counter+1
end
iteration_data = iteration_data./(repeats*num_comps);
simulated_data_z = [simulated_data_z; z_US z_US-0.08 iteration_data];
outer_counter = outer_counter+1
end

save('z_counterfactuals_baseline.mat','simulated_data_z')


load('z_counterfactuals_baseline.mat')

%%% GROWTH 
hold on
plot(simulated_data_z(1:15,1),smooth(simulated_data_z(1:15,3),10),'k','LineWidth',2.0)
ytickformat('percentage')
set(gcf,'color','white')
ax = gca
ax.YAxis.FontWeight = 'bold';
ax.XAxis.FontWeight = 'bold';
ax.YAxis.FontSize = 16
ax.XAxis.FontSize = 16
hold off

%%% RELATIVE WAGE
hold on
plot(simulated_data_z(:,1),smooth(simulated_data_z(:,4),10),'k','LineWidth',2.0)
xlabel('z US')
title('Relative Wage US/OECD')
set(gcf,'color','white')
ax = gca
ax.YAxis.FontSize = 16
ax.XAxis.FontSize = 16
hold off

%%% TRADE SHARE
hold on
plot(simulated_data_z(1:15,1),smooth(simulated_data_z(1:15,5),10),'k','LineWidth',2.0)
set(gcf,'color','white')
ax = gca
ax.YAxis.FontWeight = 'bold';
ax.XAxis.FontWeight = 'bold';
ax.YAxis.FontSize = 16
ax.XAxis.FontSize = 16
hold off

%%% TRADE ELASTICITY
hold on
plot(simulated_data_z(1:15,1),-smooth(simulated_data_z(1:15,6),10),'k','LineWidth',2.0)
xticks([0 0.05 0.1 0.15 0.2 0.25])
set(gcf,'color','white')
ax = gca
ax.YAxis.FontWeight = 'bold';
ax.XAxis.FontWeight = 'bold';
ax.YAxis.FontSize = 16
ax.XAxis.FontSize = 16
hold off


